<!--ljx 2022.9.1 测试页面  -->
<template>
  <view style="text-align: center; display: flex; flex-wrap: wrap">
    <view class="machine-list-card" :key="item.id" v-for="item in myGoodsList">
      <good
        :img="item.img"
        :describe="item.describe"
        :title="item.title"
        :price="item.price"
        :num="item.num"
        :id="item.id"
      ></good>
    </view>
  </view>
</template>

<script setup>
import { useStore } from "vuex";
import good from "./good.vue";
import { inject, onMounted, ref } from "vue";
import { getgoodlist } from "../utils/good";
const store = useStore();
//在此注入父组件index.vue中的provide的值myGoodsList
// const myGoodsList = inject("myGoodsList");
const myGoodsList = ref([]);
function mygetdata() {
  getgoodlist("")
    .then((response) => {
      console.log(response.rows);
      for (let index in response.rows) {
        let newgood = {
          id: response.rows[index],
          img: "/a1.jpg",
          title: "测试",
          describe: "新产品",
          price: 121,
          num: 3,
          memo: "无",
        };
        response.rows[index].img =
          "http://localhost/dev-api" + response.rows[index].img;
        newgood.id = response.rows[index].id;
        newgood.img = response.rows[index].img;
        newgood.title = response.rows[index].title;
        newgood.describe = response.rows[index].mydescribe;
        newgood.price = response.rows[index].price;
        newgood.num = response.rows[index].num;
        newgood.memo = response.rows[index].memo;
        myGoodsList.value.push(newgood);
      }
    })
    .catch((err) => {});
}
onMounted(()=>{
  mygetdata() 
})
</script>

<style scoped>
.machine-list-card {
  width: 350px;
  height: 200px;
  /* margin: 5px auto; */
  display: flex;
  flex-direction: row;
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 5px 5px 10px rgba(160, 160, 160, 0.3);
  margin-bottom: 10px;
  margin-right: 10px;
}

.left {
  width: 180px;
  height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.right {
  width: 200px;
  height: 200px;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.img {
  width: 170px;
  height: 170px;
}

.img image {
  width: 170px;
  height: 170px;
}

.info-item {
  display: flex;
  white-space: nowrap;
}

.info-item-title {
  /* font-weight: bold; */
  font-size: 20px;
  width: 4em;
  text-align: justify;
  text-align-last: justify;
}

.info-item-content {
  margin-left: 10px;
  overflow: hidden;
}
</style>
